﻿using System;
using System.Text;
using StaffingSystem.EF;
using System.Data.SqlClient;

namespace StaffingSystem.Business.LeaveListBusiness
{
    public class LeaveProduce
    {
        Management man = new Management();
        /// <summary>
        /// 添加请假信息
        /// </summary>
        /// <param name="llist"></param>
        /// <returns></returns>
        public int AddLeaveList(View_LeaveList llist)
        {
            try
            {
                StringBuilder procString = new StringBuilder();
                procString.Append("AddLeaveList");
                procString.Append(" @TypeID,");
                procString.Append("@LeaveReason,");
                procString.Append("@LeaveTime,");
                procString.Append("@EndTime,");
                procString.Append("@ApproveResult,");
                procString.Append("@Remark,");
                procString.Append("@Name");
          
                SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@TypeID",llist.TypeID),
                    new SqlParameter("@LeaveReason",llist.LeaveReason),
                    new SqlParameter("@LeaveTime",llist.LeaveTime),
                    new SqlParameter("@EndTime",llist.EndTime),
                    new SqlParameter("@ApproveResult",llist.ApproveResult),
                    new SqlParameter("@Remark",llist.Remark),
                    new SqlParameter("@Name",llist.Name)
                };
                int i=   man.Database.ExecuteSqlCommand(procString.ToString(), parameters);
                return i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 修改请假信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateLeaveList(View_LeaveList model)
        {
           
            try
            {
                StringBuilder procString = new StringBuilder();
                procString.Append("UpdateLeaveList");
                procString.Append(" @TypeID,");
                procString.Append("@LeaveReason,");
                procString.Append("@LeaveTime,");
                procString.Append("@EndTime,");
                procString.Append("@ApproveResult,");
                procString.Append("@Remark,");
                procString.Append("@PLID");

                SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@TypeID",model.TypeID),
                    new SqlParameter("@LeaveReason",model.LeaveReason),
                    new SqlParameter("@LeaveTime",model.LeaveTime),
                    new SqlParameter("@EndTime",model.EndTime),
                    new SqlParameter("@ApproveResult",model.ApproveResult),
                    new SqlParameter("@Remark",model.Remark),
                    new SqlParameter("@PLID",model.PLID)
                };
                int i = man.Database.ExecuteSqlCommand(procString.ToString(), parameters);
                return i;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



    }
}
